package br.com.rookgraph.run;

import java.util.Random;
import java.util.Scanner;

import br.com.rookgraph.GenerateGraph;
import br.com.rookgraph.Graph;
import br.com.rookgraph.utils.BranchReduceExecute;

public class RunCountCriteria {

	public static void main(String[] args) {
		System.out.println("CONTADOR DE VITÓRIAS DOS CRITÉRIOS DE DECISÃO");
		
		Scanner s = new Scanner(System.in);
		System.out.println("Digite o número grafos: ");
		int numG = s.nextInt();
		int i = 1;
		
		s.close();

		do {
			int numV = new Random().nextInt(40) + 10;
			int incEdge = new Random().nextInt(20) + 5;
			int qtdBranchTreeInicial = 0;

			GenerateGraph generateGraph = new GenerateGraph();
			Graph graph = generateGraph.generateWhit(numV, incEdge, false);
			
			int raiz = new Random().nextInt(numV)+1;
			Graph treeIni = graph.getTreeLarge(new Graph(graph.getOrder()), raiz);
			qtdBranchTreeInicial = treeIni.getBranchs().length;
			
			if (qtdBranchTreeInicial > 0) {
				System.out.println("Grafo " + i + " - " + numV + " vértices - densidade - " + incEdge);
				BranchReduceExecute.plus2V(graph, clone(treeIni), numG, i, numV, incEdge);
				System.out.println("");
				i++;
			}
		} while (i <= numG);
	}
	
	public static Graph clone(Graph graph){
		try {
			return (Graph) graph.clone();
		} catch (CloneNotSupportedException e) {
			throw new RuntimeException(e);
		}
	}

	
}
